{
  Базовые объекты для описания проекта

 TIntgrlActor - Пользователь или бот, работающие с данными
 TIntgrlSession - Сессия работы с данными
 TIntgrlElmntInfo - Описание элемента данных (описывает, но не определяет)
 TIntgrlGrpInfo - Набор элементов
 TIntgrlQualtyInfo - Качественное состояние (обобщает и дифференцирует элементы)
 TIntgrlFuncInfo - Одношаговое преобразование
 TIntgrlMethdInfo - Многошаговый метод
 TIntgrlElmntData - Элемент данных (определяет наличие и связи в рамках проекта)
 TIntgrlDataDefntn - Определение величин в рамках задачи

   версия 0.2 март 2011 prodg@ya.ru D.Kondakov
}
unit IIntgrlObjcts;

{$mode objfpc}{$H+}

interface

{$I calcconfig.inc}

uses
  Classes, SysUtils, IIntgrlTypes;

type
  TIntgrlActorClass = (arUser, arBot);

  { TIntgrlActor }

  TIntgrlActor = class
    constructor Create(aID: TinlID; aClass: TIntgrlActorClass);
  private
    acrID: TinlID;
    acrClass: TIntgrlActorClass;
    acrTrust: TIntgrlDataTrust;
  protected
    acrMoreInfo: pointer;
    function GetName: TinlNameType; virtual; abstract;
  public
    property arID: TinlID read acrID;
    property arClass: TIntgrlActorClass read acrClass;
    property arTrust: TIntgrlDataTrust read acrTrust;
    property arName: TinlNameType read GetName;
  end;

  TIntgrlSessionState = (ssNew, ssOpen, ssBussy, ssIdle, ssClosed);

  { TIntgrlSession }

  TIntgrlSession = class
    constructor Create(aID: TinlID; aUser: TIntgrlActor);
    destructor Destroy; override;
  private
    ssnID: TinlID;
    ssnOwner: TIntgrlActor;
    ssnState: TIntgrlSessionState;
  public
    property snID: TinlID read ssnID;
    property snCurActor: TIntgrlActor read ssnOwner;
    property snState: TIntgrlSessionState read ssnState;
  end;

  { TIntgrlElmntInfo }

  TIntgrlElmntInfo = class
    constructor Create;
    destructor Destroy; override;
  private
    iiID: TinlID;
    iiAlias: TinlNameType;
    iiHash: TinlHash;
    iiMdfTime: TinlTimeStamp;
    iiMdfctn: TinlModifctn;
    iiInfo: TinlRubricType;
    iiVrnt: array of TIntgrlElmntInfo;
    iiCmpnt: array of TIntgrlElmntInfo;
  protected
    function iiCompost: TinlLogicType; virtual;
    function iiInconst: TinlLogicType; virtual;
    function iiDefinbl: TinlLogicType; virtual;
    function iiDefined: TinlLogicType; virtual;
    function SaveStr: TinlStringType; virtual;
    procedure LoadStr(s: TinlStringType); virtual;
  public
    property Compost: TinlLogicType read iiCompost;
    property Inconst: TinlLogicType read iiInconst;
    property Definbl: TinlLogicType read iiDefinbl;
    property Defined: TinlLogicType read iiDefined;
    procedure RegID(iID: TinlID);
  end;

  { TIntgrlSetInfo }

  TIntgrlSetInfo = class(TIntgrlElmntInfo)
    constructor Create;
    destructor Destroy; override;
  private
    giVol: TinlID;
    giGrp: array of TIntgrlElmntInfo;
    procedure SetVol(const newVol: TinlID);
    function GetInfo(const i: TinlID): TIntgrlElmntInfo;
  protected
    function iiCompost: TinlLogicType; override;
    function iiDefinbl: TinlLogicType; override;
    function iiDefined: TinlLogicType; override;
    function SaveStr: TinlStringType; override;
    procedure LoadStr(s: TinlStringType); override;
  public
    property Vol: TinlID read giVol write SetVol;
    property Grp[num: TinlID]: TIntgrlElmntInfo read GetInfo; default;
  end;

  { TIntgrlQualtyInfo }

  TIntgrlQualtyInfo = class(TIntgrlElmntInfo)
    constructor Create;
    destructor Destroy; override;
  protected
    qiReq: array of TIntgrlElmntInfo;
    qiCnfl: array of TIntgrlQualtyInfo;
    function SaveStr: TinlStringType; override;
    procedure LoadStr(s: TinlStringType); override;
  end;

  { TIntgrlFuncInfo }

  TIntgrlFuncInfo = class(TIntgrlElmntInfo)
    constructor Create;
    destructor Destroy; override;
    function iiCompost: TinlLogicType; override;
    function iiDefinbl: TinlLogicType; override;
    function iiDefined: TinlLogicType; override;
    procedure CreateCode; virtual; abstract;
  protected
    fiInput: TIntgrlSetInfo;
    fiOutput: TIntgrlSetInfo;
    function SaveStr: TinlStringType; override;
    procedure LoadStr(s: TinlStringType); override;
  public
    property Input: TIntgrlSetInfo read fiInput;
    property Output: TIntgrlSetInfo read fiOutput;
  end;

  { TIntgrlMethdInfo }

  TIntgrlMethdInfo = class(TIntgrlFuncInfo)
    constructor Create;
    destructor Destroy; override;
  protected
    miUsedData: TIntgrlSetInfo;
    miTmpData: TIntgrlSetInfo;
    miAlgorthm: array of TIntgrlFuncInfo;
    function SaveStr: TinlStringType; override;
    procedure LoadStr(s: TinlStringType); override;
  public
    property Used: TIntgrlSetInfo read miUsedData;
  end;

  TIntgrlElmntData = class;

  { TIntgrlDataDefntn }

  TIntgrlDataDefntn = class
    ddElmnt: TIntgrlElmntData;
    ddImplmntn: array of TIntgrlMethdInfo;
    constructor Create;
    destructor Destroy; override;
  end;

  { TIntgrlElmntData }

  TIntgrlElmntData = class
    constructor Create;
    destructor Destroy; override;
  private
    idID: TinlID;
    idType: TIntgrlElmntInfo;
    idName: TinlNameType;
    idHash: TinlHash;
    idMdfTime: TinlTimeStamp;
    idCreatr: TIntgrlActor;
    idMdfctn: TinlModifctn;
    idInfo: TinlRubricType;
    idProttype: TIntgrlElmntData;
    idPrtpID: TinlID;
    idDefVarnts: array of TIntgrlDataDefntn;
  end;

  function NowItIs: TinlTimeStamp; inline;

implementation

{ TIntgrlActor }

constructor TIntgrlActor.Create(aID: TinlID; aClass: TIntgrlActorClass);
begin
  acrID := aID;
  acrClass := aClass;

end;

{ TIntgrlSession }

constructor TIntgrlSession.Create(aID: TinlID; aUser: TIntgrlActor);
begin
  ssnID := aID;
  ssnOwner := aUser;

end;

destructor TIntgrlSession.Destroy;
begin

  inherited;
end;

{ TIntgrlElmntInfo }

constructor TIntgrlElmntInfo.Create;
begin
  iiInfo := nil;
  iiVrnt := nil;
  iiCmpnt := nil;
end;

destructor TIntgrlElmntInfo.Destroy;
begin

  inherited;
end;

function TIntgrlElmntInfo.iiCompost: TinlLogicType;
begin
  result := false;
end;

function TIntgrlElmntInfo.iiInconst: TinlLogicType;
begin
  result := false;
end;

function TIntgrlElmntInfo.iiDefinbl: TinlLogicType;
begin
  result := true;
end;

function TIntgrlElmntInfo.iiDefined: TinlLogicType;
begin
  result := false;
end;

function TIntgrlElmntInfo.SaveStr: TinlStringType;
begin

end;

procedure TIntgrlElmntInfo.LoadStr(s: TinlStringType);
begin

end;

procedure TIntgrlElmntInfo.RegID(iID: TinlID);
begin
  iiID := iID;
end;

{ TIntgrlSetInfo }

constructor TIntgrlSetInfo.Create;
begin
  inherited;

end;

destructor TIntgrlSetInfo.Destroy;
begin

  inherited;
end;

procedure TIntgrlSetInfo.SetVol(const newVol: TinlID);
begin
  if (giVol=newVol) or Inconst then exit;
  giVol := newVol;
end;

function TIntgrlSetInfo.GetInfo(const i: TinlID): TIntgrlElmntInfo;
begin

end;

function TIntgrlSetInfo.iiCompost: TinlLogicType;
begin
  result := true;
end;

function TIntgrlSetInfo.iiDefinbl: TinlLogicType;
begin
  result := true;
end;

function TIntgrlSetInfo.iiDefined: TinlLogicType;
begin
  result := false;
end;

function TIntgrlSetInfo.SaveStr: TinlStringType;
begin
  Result:=inherited SaveStr;
end;

procedure TIntgrlSetInfo.LoadStr(s: TinlStringType);
begin
  inherited LoadStr(s);
end;

{ TIntgrlQualtyInfo }

constructor TIntgrlQualtyInfo.Create;
begin

end;

destructor TIntgrlQualtyInfo.Destroy;
begin
  inherited Destroy;
end;

function TIntgrlQualtyInfo.SaveStr: TinlStringType;
begin
  Result:=inherited SaveStr;
end;

procedure TIntgrlQualtyInfo.LoadStr(s: TinlStringType);
begin
  inherited LoadStr(s);
end;

{ TIntgrlFuncInfo }

constructor TIntgrlFuncInfo.Create;
begin
  inherited;

end;

destructor TIntgrlFuncInfo.Destroy;
begin

  inherited;
end;

function TIntgrlFuncInfo.iiCompost: TinlLogicType;
begin
  result := fiOutput.Vol>1;
end;

function TIntgrlFuncInfo.iiDefinbl: TinlLogicType;
begin
  result := false;
end;

function TIntgrlFuncInfo.iiDefined: TinlLogicType;
begin
  result := true;
end;

function TIntgrlFuncInfo.SaveStr: TinlStringType;
begin
  Result:=inherited SaveStr;
end;

procedure TIntgrlFuncInfo.LoadStr(s: TinlStringType);
begin
  inherited LoadStr(s);
end;

{ TIntgrlMethdInfo }

constructor TIntgrlMethdInfo.Create;
begin
  inherited;

end;

destructor TIntgrlMethdInfo.Destroy;
begin

  inherited;
end;

function TIntgrlMethdInfo.SaveStr: TinlStringType;
begin
  Result:=inherited SaveStr;
end;

procedure TIntgrlMethdInfo.LoadStr(s: TinlStringType);
begin
  inherited LoadStr(s);
end;

{ TIntgrlElmntData }

constructor TIntgrlElmntData.Create;
begin

end;

destructor TIntgrlElmntData.Destroy;
begin
  inherited Destroy;
end;

{ TIntgrlDataDefntn }

constructor TIntgrlDataDefntn.Create;
begin

end;

destructor TIntgrlDataDefntn.Destroy;
begin
  inherited Destroy;
end;

function NowItIs: TinlTimeStamp;
begin
  result := DateTimeToTimeStamp(Now);
end;

end.

